<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <title>Edit User</title>
</head>
<body>
<div class="nav">
  <span class="menuButton"><g:link class="list" action="list">User List</g:link></span>
  <span class="menuButton"><g:link class="create" action="create">New User</g:link></span>
</div>
<div class="body">
  <h1>Edit User</h1>
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <g:hasErrors bean="${userInstance}">
    <div class="errors">
      <g:renderErrors bean="${userInstance}" as="list"/>
    </div>
  </g:hasErrors>
  <g:form method="post">
    <input type="hidden" name="id" value="${userInstance?.id}"/>
    <input type="hidden" name="version" value="${userInstance?.version}"/>
    <div class="dialog">
      <table>
        <tbody>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="username">Username:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'username', 'errors')}">
            <input type="text" id="username" name="username" value="${fieldValue(bean: userInstance, field: 'username')}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="passwd">Passwd:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'passwd', 'errors')}">
            <input type="password" id="passwd" name="passwd" value=""/>
          </td>
        </tr>

        <tr class="prop">
            <td valign="top" class="name">
                <label for="pass">Repeat Passwd:</label>
            </td>
            <td valign="top" class="value ${hasErrors(bean:userInstance,field:'passwd','errors')}">
                <input type="password" id="pass" name="pass" value=""/>
            </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="profile">Profile:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'profile', 'errors')}">
            <g:link controller="profile" action="show" id="${userInstance?.profile?.id}">User Profile</g:link>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="enabled">Enabled:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'enabled', 'errors')}">
            <g:checkBox name="enabled" value="${userInstance?.enabled}"></g:checkBox>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="eventAlert">Event Alert:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'eventAlert', 'errors')}">
            <g:checkBox name="eventAlert" value="${userInstance?.eventAlert}"></g:checkBox>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="dailyDigest">Daily Digest:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'dailyDigest', 'errors')}">
            <g:checkBox name="dailyDigest" value="${userInstance?.dailyDigest}"></g:checkBox>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="weeklyDigest">Weekly Digest:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'weeklyDigest', 'errors')}">
            <g:checkBox name="weeklyDigest" value="${userInstance?.weeklyDigest}"></g:checkBox>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="authorities">Authorities:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'authorities', 'errors')}">

          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="events">Events:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'events', 'errors')}">

            <ul>
              <g:each var="e" in="${userInstance?.events?}">
                <li><g:link controller="event" action="show" id="${e.id}">${e?.encodeAsHTML()}</g:link></li>
              </g:each>
            </ul>
            <g:link controller="event" params="['user.id':userInstance?.id]" action="create">Add Event</g:link>

          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name">
            <label for="feedInfos">Feed Infos:</label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'feedInfos', 'errors')}">

            <ul>
              <g:each var="f" in="${userInstance?.feedInfos?}">
                <li><g:link controller="feedInfo" action="show" id="${f.id}">${f?.encodeAsHTML()}</g:link></li>
              </g:each>
            </ul>
            <g:link controller="feedInfo" params="['user.id':userInstance?.id]" action="create">Add FeedInfo</g:link>

          </td>
        </tr>

        </tbody>
      </table>
    </div>
    <div class="buttons">
      <span class="button"><g:actionSubmit class="save" value="Update"/></span>
      <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete"/></span>
    </div>
  </g:form>
</div>
</body>
</html>
